<!--
 * @Author: your name
 * @Date: 2022-03-15 11:12:29
 * @LastEditTime: 2022-03-15 11:49:37
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \geyao\geyao\前端this指向问题普通函数220315.html
-->
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>前端this指向问题普通函数</title>
</head>

<body>
  <script>
    //口诀 谁调用就会指向谁 这边是普通函数 直接报错this.fang is not a function
    var name = "geyao"
    var fangfang = {
      name: "fangfang",

      fang: function () {
        console.log(this.name)
      },

      fun: function () {

        setTimeout(() => {
          this.fang()
        }, 100);
      }

    };
    fangfang.fun()
  </script>

</body>

</html>